package com.shawn.springboot.integeration.netty.client;


import com.shawn.springboot.integeration.netty.exception.ApiException;
import com.shawn.springboot.integeration.netty.model.ServerAddress;
import com.shawn.springboot.integeration.netty.msg.Request;
import com.shawn.springboot.integeration.netty.msg.Response;

import java.util.concurrent.TimeUnit;

/**
 * @author zhangjian
 * @title: Client
 * @projectName 12-springboot学习
 * @description: Tcp通信客户端
 * @date 2021/4/2710:55
 */
public interface IClient {
    long DEFAULT_TIMEOUT = 30;                          //默认同步请求超时时间
    TimeUnit DEFAULT_TIMEOUT_UNIT = TimeUnit.SECONDS;   // 默认请求超时时间单位
    boolean asyncReq(Request req);                      // 异步请求
    Response syncReq(Request req) throws ApiException;  // 同步请求
    Response syncReq(Request req,long timeout,TimeUnit timeUnit) throws ApiException;
    ServerAddress getServerAddress();                   //  获取服务端地址
    void close();                                       //  关闭客户端
    boolean isConnected();                              //  客户端是否与服务器端连接成功
    String getClientId();                               //  获取客户端唯一编号
}
